-------------------------------------------------------------------------------
-- Archivo:                      comparation_unit.vhdl
-- Fecha de creación:            18/01/2011
-- Ultima fecha de modificacion: 30/01/2011
-- Diseñador:                    Samantha Gamboa.
-- Diseño:                       comparation_unit
-- Propósito:                    Unidad de comparacion de dirección de 
--                               registros de las instrucciones en la cola
--				 de instrucciones.
-------------------------------------------------------------------------------

-- libreria IEEE
library IEEE;
use IEEE.std_logic_1164.all; 

--Diseño de la entidad (caja negra)
entity comparation_unit is
	port(
   	--ENTRADAS
   	CURR_INST_i : in std_logic_vector(11 downto 0);
   	NEXT_INST_i : in std_logic_vector(11 downto 0);
	   
	--SALIDAS
	EQ45_45_o : out std_logic;
	EQ45_67_o : out std_logic;
	EQ45_89_o : out std_logic;
	EQ67_45_o : out std_logic;
	EQ67_67_o : out std_logic;
	EQ67_89_o : out std_logic;
	EQ89_45_o : out std_logic;
	EQ89_67_o : out std_logic;
	EQ89_89_o : out std_logic
	);
end comparation_unit;

--Diseño  de especificacion de comportamiento
architecture behavioral of comparation_unit is 
--Declaraciones
	signal curr_ins : std_logic_vector(11 downto 0);
	signal next_ins : std_logic_vector(11 downto 0);
begin 
--Comportamiento 
	curr_ins <= CURR_INST_i;
	next_ins <= NEXT_INST_i;

	-- Design   0  1  2  3  4  5  6  7  8  9  10  11
	-- 	   ------------ ----- ----- ----- ------
	-- 	  |  |  |  |  |  |  |  |  |  |  |  |  | 
	-- 	   ------------ ----- ----- ----- ------
	-- VHDL    11  10 9  8  7  6  5  4  3  2  1  0
	 
	EQ45_45_o <= '1' when curr_ins(7 downto 6) = next_ins(7 downto 6) else '0'; 
	EQ45_67_o <= '1' when curr_ins(7 downto 6) = next_ins(5 downto 4) else '0';
	EQ45_89_o <= '1' when curr_ins(7 downto 6) = next_ins(3 downto 2) else '0';

	EQ67_45_o <= '1' when curr_ins(5 downto 4) = next_ins(7 downto 6) else '0'; 
	EQ67_67_o <= '1' when curr_ins(5 downto 4) = next_ins(5 downto 4) else '0';
	EQ67_89_o <= '1' when curr_ins(5 downto 4) = next_ins(3 downto 2) else '0';

	EQ89_45_o <= '1' when curr_ins(3 downto 2) = next_ins(7 downto 6) else '0'; 
	EQ89_67_o <= '1' when curr_ins(3 downto 2) = next_ins(5 downto 4) else '0';
	EQ89_89_o <= '1' when curr_ins(3 downto 2) = next_ins(3 downto 2) else '0';
end behavioral;

